home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / dopus412-gpl / dopus_print / dopusbase.h < prev    next >
C/C++ Source or Header  |  2000-02-28  |  15KB  |  399 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. /*
  32.  *
  33.  * dopus.library header file
  34.  *
  35.  * Support library for Directory Opus version 3.50+
  36.  *
  37.  * (c) Copyright 1992 Jonathan Potter
  38.  *
  39.  */
  40.  
  41. /* Library base structure */
  42.  
  43. struct DOpusBase {
  44.     struct Library LibNode;
  45.     UBYTE Flags;
  46.     UBYTE pad;
  47.     struct ExecBase *ExecBase;
  48.     struct DosLibrary *DOSBase;
  49.     struct IntuitionBase *IntuitionBase;
  50.     struct GfxBase *GfxBase;
  51.     struct LayersBase *LayersBase;
  52.     /* Private stuff */
  53.     ULONG pdb_cycletop;
  54.     ULONG pdb_cyclebot;
  55.     ULONG pdb_check;
  56.     ULONG pad1;
  57.     ULONG pad2;
  58.     ULONG pad3;
  59.     ULONG pad4;
  60.     ULONG pdb_Flags;
  61.     ULONG SegList;
  62. };
  63.  
  64. /* File requester definition structure */
  65.  
  66. #define DIRBUF_SIZE  256
  67. #define FILEBUF_SIZE 32
  68.  
  69. struct DOpusFileReq {
  70.     char *title;            /* Requester title or NULL for default    */
  71.     char *dirbuf,*filebuf;  /* Buffers for directory and filenames    */
  72.     struct Window *window;  /* Window in screen to appear on          */
  73.     int x,y;                /* x & y position of requester window     */
  74.     int lines;              /* Number of files to display at once     */
  75.     ULONG flags;            /* Flags; see below                       */
  76.     struct DOpusRemember
  77.         *filearraykey;        /* Remember structure for multiple files  */
  78.     char **filearray;       /* Array of multiple files (DFRF_MULTI)   */
  79. };
  80.  
  81. /* Requester flags */
  82.  
  83. #define DFRB_DIRREQ 0 /* Directory requester - no files        */
  84. #define DFRB_MULTI  1 /* Can select more than one file at once */
  85. #define DFRB_SAVE   2 /* Save requester                        */
  86. #define DFRB_FONT   3 /* Font requester                        */
  87.  
  88. #define DFRF_DIRREQ (1<<DFRB_DIRREQ)
  89. #define DFRF_MULTI  (1<<DFRB_MULTI)
  90. #define DFRF_SAVE   (1<<DFRB_SAVE)
  91. #define DFRF_FONT   (1<<DFRB_FONT)
  92.  
  93. /* return values of FileRequest() */
  94.  
  95. #define RETURN_OKAY    1
  96. #define RETURN_CANCEL  0
  97. #define ERROR_NOMEM   -1
  98.  
  99. /* return values of CompareLock() */
  100.  
  101. #define LOCK_DIFFERENT   -1
  102. #define LOCK_SAME         0
  103. #define LOCK_SAME_VOLUME  1
  104.  
  105. /* return values of Assign() */
  106.  
  107. #define ASSIGN_OK     0
  108. #define ASSIGN_NODEV  1
  109. #define ASSIGN_NOMEM  2
  110. #define ASSIGN_CANCEL 3
  111.  
  112. /* DOpusDateTime structure for StampToStr() and StrToStamp() */
  113.  
  114. struct DOpusDateTime {
  115.     struct DateStamp dat_Stamp; /* DOS Datestamp               */
  116.     UBYTE dat_Format;           /* Sets the date string format */
  117.     UBYTE dat_Flags;            /* Flags; see below            */
  118.     char *dat_StrDay;           /* day of the week string      */
  119.     char *dat_StrDate;          /* date string                 */
  120.     char *dat_StrTime;          /* time string                 */
  121.     char **custom_weekdays;     /* array of weekday names      */
  122.     char **custom_shortweekdays;/* array of short weekday names*/
  123.     char **custom_months;       /* array of month names        */
  124.     char **custom_shortmonths;  /* array of short month names  */
  125.     char **custom_special_days; /* array of special days       */
  126. };
  127.  
  128. #define DDTB_SUBST  0 /* Substitute "Today","Tomorrow" where appropriate */
  129. #define DDTB_FUTURE 1 /* "Monday", etc. refers to next not last day      */
  130.  
  131. #define DDTB_CUSTOM 6 /* Custom strings */
  132. #define DDTB_12HOUR 7 /* 12-hour time */
  133.  
  134. #define DDTF_SUBST  (1<<DDTB_SUBST)
  135. #define DDTF_FUTURE (1<<DDTB_FUTURE)
  136.  
  137. #define DDTF_CUSTOM (1<<DDTB_CUSTOM)
  138. #define DDTF_12HOUR (1<<DDTB_12HOUR)
  139.  
  140. #define FORMAT_DOS 0 /* dd-mmm-yy */
  141. #define FORMAT_INT 1 /* yy-mm-dd  */
  142. #define FORMAT_USA 2 /* mm-dd-yy  */
  143. #define FORMAT_CDN 3 /* dd-mm-yy  */
  144. #define FORMAT_AUS FORMAT_CDN
  145.  
  146. /* ListView definition structure */
  147.  
  148. struct DOpusListView {
  149.     ULONG listid;          /* Unique ID number                           */
  150.     struct Window *window; /* Window to add the ListView to              */
  151.     int x,y;               /* x & y position of ListView                 */
  152.     int w,h;               /* Width and height of ListView               */
  153.     char *title;           /* Title of ListView                          */
  154.     char **items;          /* Null-terminated array of items to display  */
  155.     char *selectarray;     /* Table of selection status used with        */
  156.                            /*   DLVB_MULTI. See docs for more info.      */
  157.     ULONG flags;           /* Flags; see below                           */
  158.     int sliderwidth;       /* Width of slider                            */
  159.     int slidercol;         /* Pen colour of slider, -1 for default       */
  160.     int sliderbgcol;       /* Pen colour of slider background            */
  161.     int textcol;           /* Pen colour of general text, -1 for default */
  162.     int boxhi,boxlo;       /* Pen colours of 3D box, -1 for defaults     */
  163.     int arrowfg,arrowbg;   /* Arrow fg/bg colours, -1 for defaults       */
  164.     int itemfg,itembg;     /* Item fg/bg colours, -1 for defaults        */
  165.     int topitem;           /* First item displayed                       */
  166.     int itemselected;      /* Item just clicked on                       */
  167.     struct DOpusListView
  168.         *next;               /* Next ListView to add to window or NULL     */
  169.     /* Private stuff */
  170.     int oldoffset,count,lines,columns;
  171.     struct DOpusRemember *key;
  172.     struct Gadget *listgads;
  173.     struct Image *listimage;
  174.     struct PropInfo *listprop;
  175.     struct Region *listregion;
  176.     int gadadd,fw,fh,fb,xo,yo,mx,my,chk,ty;
  177.     char ofg,obg,odm;
  178.     char *selected;
  179. };
  180.  
  181. /* ListView flags */
  182.  
  183. #define DLVB_MULTI  0 /* Can multi-select items                              */
  184. #define DLVB_LEAVE  1 /* Leave item selected                                 */
  185. #define DLVB_CHECK  2 /* Select with check marks, used with MULTI and LEAVE  */
  186. #define DLVB_TOGGLE 3 /* Used with LEAVE to toggle item on/off               */
  187. #define DLVB_SLOW   4 /* Specify slow scrolling                              */
  188. #define DLVB_DUMB   5 /* Dumb list; display only - no mouse selection        */
  189. #define DLVB_TTOP   6 /* Title at the top of the list (default to the left)  */
  190. #define DLVB_ENDNL  7 /* End list with a null-string as well as NULL pointer */
  191. #define DLVB_HIREC  8 /* Highlight by recessed borders                       */
  192.  
  193. #define DLVF_MULTI  (1<<DLVB_MULTI)
  194. #define DLVF_LEAVE  (1<<DLVB_LEAVE)
  195. #define DLVF_CHECK  (1<<DLVB_CHECK)
  196. #define DLVF_TOGGLE (1<<DLVB_TOGGLE)
  197. #define DLVF_SLOW   (1<<DLVB_SLOW)
  198. #define DLVF_DUMB   (1<<DLVB_DUMB)
  199. #define DLVF_TTOP   (1<<DLVB_TTOP)
  200. #define DLVF_ENDNL  (1<<DLVB_ENDNL)
  201. #define DLVF_HIREC  (1<<DLVB_HIREC)
  202.  
  203. /* DOpusListView->selectarray flags */
  204.  
  205. #define LVARRAY_SELECTED     1   /* Item is selected */
  206. #define LVARRAY_DISABLED     2   /* Item is disabled */
  207.  
  208. /* DOpusRemember structure, used by LAllocRemember() and LFreeRemember() */
  209.  
  210. struct DOpusRemember {
  211.     struct DOpusRemember *next,*current;
  212.     ULONG size;
  213. };
  214.  
  215. /* Right mouse button gadget text */
  216.  
  217. struct RMBGadgetText {
  218.     char *text;                    /* Text string                      */
  219.     int x,y;                       /* x and y coordinates of text      */
  220.     int w,h;                       /* Width and Height of text area    */
  221.     int fg,bg;                     /* Fg and Bg pens                   */
  222. };
  223.  
  224. /* Right mouse button gadget structure, used by RMBGadget */
  225.  
  226. struct RMBGadget {
  227.     struct RMBGadget *next;        /* Next RMBGadget                 */
  228.     int x,y;                       /* x and y coordinates            */
  229.     int w,h;                       /* Width and Height               */
  230.     int flags;                     /* Flags; see below               */
  231.     int id;                        /* ID number of this RMBGadget    */
  232.     struct RMBGadgetText txt[2];   /* Alternate gadget text displays */
  233.     struct Border *high_bord[2];   /* Borders to highlight with      */
  234. };
  235.  
  236. #define RGB_ALTTEXT 0  /* This gadget has alternate text displays */
  237. #define RGB_ALTBORD 1  /* Highlight with borders */
  238.  
  239. #define RGF_ALTTEXT (1<<RGB_ALTTEXT)
  240. #define RGF_ALTBORD (1<<RGB_ALTBORD)
  241.  
  242. /* Defines used for AddGadgets */
  243.  
  244. #define GAD_NONE  -1
  245. #define GAD_CYCLE 1
  246. #define GAD_CHECK 2
  247. #define GAD_RADIO 3
  248. #define GAD_GLASS 4
  249.  
  250. /* SimpleRequest structure */
  251.  
  252. struct DOpusSimpleRequest {
  253.     char *text;                 /* Text to display            */
  254.     char **gads;                /* Gadget names               */
  255.     int *rets;                  /* Gadget return values       */
  256.     int hi,lo;                  /* 3D hi and lo pen colours   */
  257.     int fg,bg;                  /* Text Fg and Bg pen colours */
  258.     char *strbuf;               /* Buffer for string gadget   */
  259.     int strlen;                 /* Maximum string length      */
  260.     int flags;                  /* Flags, see below           */
  261.     struct TextFont *font;      /* Font to use, must be open  */
  262.     int value;                  /* Value for booleans         */
  263.     char *title;                /* Title for req with borders */
  264. };
  265.  
  266. #define SRB_LONGINT   0  /* Integer gadget                          */
  267. #define SRB_CENTJUST  1  /* Center justify string (left is default) */
  268. #define SRB_RIGHTJUST 2  /* Right justify string (left is default)  */
  269. #define SRB_GLASS     3  /* Glass gadget                            */
  270. #define SRB_DIRGLASS  4  /* Glass gadget is for directory requester */
  271. #define SRB_BORDERS   5  /* Requester borders                       */
  272. #define SRB_NOCENTER  6  /* Don't center text in requester          */
  273. #define SRB_RECESSHI  7  /* Highlight gadgets by recessing          */
  274.  
  275. #define SRF_LONGINT   (1<<SRB_LONGINT)
  276. #define SRF_CENTJUST  (1<<SRB_CENTJUST)
  277. #define SRF_RIGHTJUST (1<<SRB_RIGHTJUST)
  278. #define SRF_GLASS     (1<<SRB_GLASS)
  279. #define SRF_DIRGLASS  (1<<SRB_DIRGLASS)
  280. #define SRF_BORDERS   (1<<SRB_BORDERS)
  281. #define SRF_NOCENTER  (1<<SRB_NOCENTER)
  282. #define SRF_RECESSHI  (1<<SRB_RECESSHI)
  283.  
  284.  
  285. /* Function prototypes */
  286.  
  287. void ActivateStrGad(struct Gadget *,struct Window *);
  288. AddGadgets(struct Window *,struct Gadget *,char **,int,int,int,int);
  289. AddListView(struct DOpusListView *,int);
  290. Assign(char *,char *);
  291. Atoh(char *,int);
  292. char *BaseName(char *);
  293. void BtoCStr(BSTR,char *,int);
  294. CheckExist(char *,int *);
  295. CheckHexGad(struct Gadget *,struct Window *,int,int);
  296. CheckNumGad(struct Gadget *,struct Window *,int,int);
  297. CompareDate(struct DateStamp *,struct DateStamp *);
  298. CompareLock(BPTR,BPTR);
  299. void Decode_RLE(char *source,char *dest,int size);
  300. void DisableGadget(struct Gadget *,struct RastPort *,int,int);
  301. void Do3DBox(struct RastPort *,int,int,int,int,int,int);
  302. void Do3DCycleBox(struct RastPort *,int,int,int,int,int,int);
  303. void Do3DFrame(struct RastPort *,int,int,int,int,char *,int,int);
  304. void Do3DStringBox(struct RastPort *,int,int,int,int,int,int);
  305. void DoArrow(struct RastPort *,int,int,int,int,int,int,int);
  306. void DoCycleGadget(struct Gadget *,struct Window *,char **,int);
  307. void DoGlassImage(struct RastPort *,struct Gadget *,int,int,int);
  308. DoRMBGadget(struct RMBGadget *,struct Window *);
  309. DoSimpleRequest(struct Window *,struct DOpusSimpleRequest *);
  310. void DrawCheckMark(struct RastPort *,int,int,int);
  311. void EnableGadget(struct Gadget *,struct RastPort *,int,int);
  312. FileRequest(struct DOpusFileReq *);
  313. void FixSliderBody(struct Window *,struct Gadget *,int,int,int);
  314. void FixSliderPot(struct Window *,struct Gadget *,int,int,int,int);
  315. GetSliderPos(struct Gadget *,int,int);
  316. void GetWBScreen(struct Screen *);
  317. void GhostGadget(struct Gadget *,struct RastPort *,int,int);
  318. void HiliteGad(struct Gadget *,struct RastPort *);
  319. void *LAllocRemember(struct DOpusRemember **,ULONG,ULONG);
  320. struct IORequest *LCreateExtIO(struct MsgPort *,int);
  321. struct MsgPort *LCreatePort(char *,int);
  322. void LDeleteExtIO(struct IORequest *);
  323. void LDeletePort(struct MsgPort *);
  324. void LFreeRemEntry(struct DOpusRemember **,char *);
  325. void LFreeRemember(struct DOpusRemember **);
  326. struct DOpusListView *ListViewIDCMP(struct DOpusListView *,struct IntuiMessage *);
  327. LMatchPattern(char *,char *);
  328. LMatchPatternI(char *,char *);
  329. void LParsePattern(char *,char *);
  330. void LParsePatternI(char *,char *);
  331. void LSprintf(char *,char *,...);
  332. void LStrCat(char *,char *);
  333. LStrCmp(char *,char *);
  334. LStrCmpI(char *,char *);
  335. void LStrCpy(char *,char *);
  336. void LStrnCat(char *,char *,int);
  337. LStrnCmp(char *,char *,int);
  338. LStrnCmpI(char *,char *,int);
  339. void LStrnCpy(char *,char *,int);
  340. char LToLower(char);
  341. char LToUpper(char);
  342. PathName(BPTR,char *,int);
  343. Random(int);
  344. RawkeyToStr(USHORT,USHORT,char *,char *,int);
  345. RefreshListView(struct DOpusListView *,int);
  346. void RefreshStrGad(struct Gadget *,struct Window *);
  347. RemoveListView(struct DOpusListView *,int);
  348. SearchPathList(char *,char *,int);
  349. void Seed(int);
  350. SendPacket(struct MsgPort *,int,ULONG *,int);
  351. void SetBusyPointer(struct Window *);
  352. void ShowSlider(struct Window *,struct Gadget *);
  353. StampToStr(struct DOpusDateTime *);
  354. StrCombine(char *,char *,char *,int);
  355. StrConcat(char *,char *,int);
  356. void StrToLower(char *,char *);
  357. StrToStamp(struct DOpusDateTime *);
  358. void StrToUpper(char *,char *);
  359. TackOn(char *,char *,int);
  360. void UScoreText(struct RastPort *,char *,int,int,int);
  361. struct Image *GetButtonImage(int,int,int,int,int,int,struct DOpusRemember **);
  362. void DrawRadioButton(struct RastPort *,int,int,int,int,int,int);
  363. struct Image *GetCheckImage(int,int,int,struct DOpusRemember **);
  364. struct Window *OpenRequester(struct RequesterBase *);
  365. void CloseRequester(struct RequesterBase *);
  366. APTR AddRequesterObject(struct RequesterBase *,struct TagItem *);
  367. void RefreshRequesterObject(struct RequesterBase *,struct RequesterObject *);
  368. void ObjectText(struct RequesterBase *,short,short,short,short,char *,short);
  369. void CreateGadgetBorders(struct DOpusRemember **,int,int,struct Border **,struct Border **,int,int,int);
  370. void AddGadgetBorders(struct DOpusRemember **,struct Gadget *,int,int,int);
  371. void SelectGadget(struct Window *,struct Gadget *);
  372.  
  373. /* DOpus-private functions */
  374.  
  375. ReadConfig(char *,struct ConfigStuff *);
  376. SaveConfig(char *,struct ConfigStuff *);
  377. DefaultConfig(struct ConfigStuff *);
  378. GetDevices(struct ConfigStuff *);
  379. AssignGadget(struct ConfigStuff *,int,int,char *,char *);
  380. AssignMenu(struct ConfigStuff *,int,char *,char *);
  381. FreeConfig(struct ConfigStuff *);
  382. CheckConfig(struct ConfigStuff *);
  383. FindSystemFile(char *,char *,int,int);
  384. ReadStringFile(struct StringData *,char *);
  385. FreeStringFile(struct StringData *);
  386.  
  387. #define SYSFILE_COMMAND    0
  388. #define SYSFILE_DATA       1
  389. #define SYSFILE_LIBRARY    2
  390. #define SYSFILE_REXX       3
  391. #define SYSFILE_MODULE     4
  392. #define SYSFILE_REQUESTER  5
  393.  
  394. #define ERROR_NOT_CONFIG -1
  395.  
  396. #ifndef DOPUS_PRAG
  397. #include "dopuspragmas.h"
  398. #endif
  399.